//
//  WMDefineMethod.h
//  WaiMai
//
//  Created by Angela on 2017/8/24.
//  Copyright © 2017年 Angela. All rights reserved.
//

#ifndef WMDefineMethod_h
#define WMDefineMethod_h
//DEBUG  模式下打印日志,当前行
#if (DEBUG || TEST || PRERELEASE)
#define NSLog(FORMAT, ...) fprintf(stderr,"%s\n",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif
//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] integerValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]
//手机系统判断
#define IS_IOS_7 ([GlobalUtils getDeviceSystemVersion] >= 7 )
#define IS__IOS_LOW_7 ([GlobalUtils getDeviceSystemVersion] < 7)
#define IS_IOS_8 ([GlobalUtils getDeviceSystemVersion] >= 8 )
//判断手机型号
#define iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define isRetina_4InchWidth ([[UIScreen mainScreen] currentMode].size.width == 640.0f ) || ([[UIDevice currentDevice].model hasPrefix:@"iPad"]) ? YES : NO
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define iPhone6PlusZoomModel ([[UIScreen mainScreen] currentMode].size.width == 1125.0f) ? YES : NO
// rgb颜色转换（16进制->10进制）
#define UIColorFromRGBA(rgbValue, a)    ([UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(a)])
#define UIColorFromRGB(rgbValue)    ([UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0])
#define COLOR_RGB(r, g, b)    [UIColor colorWithRed:((r)/255.0) green:((g)/255.0) blue:((b)/255.0) alpha:1.0]
#define COLOR_RGBA(r, g, b, a) [UIColor colorWithRed:((r)/255.0) green:((g)/255.0) blue:((b)/255.0) alpha:(a)]

//物理屏幕宽度
#define ScreenWidth  [UIScreen mainScreen].bounds.size.width
#define ScreenHeight [UIScreen mainScreen].bounds.size.height
////屏幕适配,按照比例适配原则
static __inline__ __attribute__((always_inline)) CGFloat realValue6(value) {
    static CGFloat realScreenWidth;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        realScreenWidth = [UIScreen mainScreen].bounds.size.width / 750.0f;
    });
    return value * realScreenWidth;
}

#define realValue6p(value) ((value)/1224.0f*ScreenWidth)
#define realValue5(value) ((value)/640.0f*ScreenWidth)
#define realValue6H(value) ((value)*(ScreenHeight/1334.0f))
/////
//定义Rect
#define rect(x, y, w, h) CGRectMake(x,y,w,h)
#endif /* WMDefineMethod_h */
